package com.xm.xmapp;

import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.android.volley.VolleyError;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.myinterface.DisssmissInterFace;
import com.xm.xmapp.myinterface.GetDataInterFace;
import com.xm.xmapp.request.bean.Get_system_message_by_idRequest;
import com.xm.xmapp.response.bean.ResponseSystemMessageById;

public class MessageDetailsActivity extends BaseActivity {

	private TextView message_time, message_title;
	private WebView message_content;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_messagedetails);
	}

	@Override
	public void initView() {

		message_time = (TextView) findViewById(R.id.message_time);
		message_content = (WebView) findViewById(R.id.message_content);
		message_title = (TextView) findViewById(R.id.message_title);
	}

	@Override
	public void initData() {
		setMyTitle("系统消息");
		String id = getIntent().getStringExtra("id");
		getData(id);
	}

	private void getData(String system_message_id) {

		Get_system_message_by_idRequest requestBean = new Get_system_message_by_idRequest();
		requestBean.message_id = system_message_id;
		promptDialog.show();
		MyAppcation.getMyAppcation().getPostData(this, requestBean, new GetDataInterFace<String>() {

			@Override
			public void onResponse(String response) {

				promptDialog.dismiss();
				ResponseSystemMessageById bean = JSON.parseObject(response, ResponseSystemMessageById.class);
				if (bean != null) {
					message_time.setText(bean.modified_on);
					message_content.loadDataWithBaseURL(null, bean.system_message_content, "text/html", "utf-8", null);
					String title = "";
					if (bean.city_name != null && !bean.city_name.equals("")) {
						title = "【" + bean.city_name + "】";
					}
					title = title + bean.system_message_title;
					message_title.setText(title);
				}

			}
		}, new DisssmissInterFace() {

			@Override
			public void putError(VolleyError error) {
				promptDialog.dismiss();
			}
		});
	}

	@Override
	public void initEvent() {
	}

}
